package logic

import (
	"context"
	"person/personrpc/personrpcclient"

	"person/api/internal/svc"
	"person/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PersonAiUploadLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPersonAiUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PersonAiUploadLogic {
	return &PersonAiUploadLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PersonAiUploadLogic) PersonAiUpload(req *types.PersonAiUploadRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	upload, err := l.svcCtx.PersonRpc.PersonAiUpload(l.ctx, &personrpcclient.PersonAiUploadRequest{
		PersonId:            req.PersonId,
		Name:                req.Name,
		MarriageAndMarriage: req.MarriageAndMarriage,
		IdImage:             req.IdImage,
		UserId:              req.UserId,
		Sex:                 req.Sex,
		DateOfBirth:         req.DateOfBirth,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "个人信息修改成功",
		Code:    200,
		Data:    upload,
	}, nil
}
